import java.util.List;
import java.util.Scanner;

public class StudentDAO {
    public void displayAllInfo(List <?extends Student>o){
        if(o==null||o.size()==0){
            System.out.println("当前学生管理系统中没有学生!!!");
            return ;
        }
        for (int i = 0; i <o.size() ; i++) {
            System.out.println(o.get(i).toString());
        }
    }

   public void addStudentInfo(Student stu){
        if(stu==null){
            return;
        }
    StudentAction m=new StudentAction();
    if(m.isExist(stu)!=-1){
        System.out.println("该学号已经存在!!!");
        return;
    }
       StudentData.stuAdd(stu);
       System.out.println("成功新增学生信息!");
   }

    public void deleteStudentInfo(String stuNo) {
        StudentAction m = new StudentAction();
        for (int i = 0; i < StudentData.num; i++) {
            if(StudentData.getStudent(i).getterStuNo().equals(stuNo)){
                StudentData.stuDelete(StudentData.getStudent(i));
            }
        }
        System.out.println("成功删除学生信息!");
    }

   public  void updataStudentInfo(String stuNo){
       int i = 0;
       for (; i < StudentData.num; i++) {
           if(StudentData.getStudent(i).getterStuNo().equals(stuNo)) {
               Scanner sc=new Scanner(System.in);
               System.out.println("输入姓名:");
               String b=sc.nextLine();
               System.out.println("输入性别:");
               String c=sc.nextLine();
               System.out.println("输入年龄");
               int d=sc.nextInt();
               StudentData.stuSet(new Student(stuNo,b,c,d),i);
               return;
           }
       }
       if(i==StudentData.num){
           System.out.println("没有该学生!!!");
       }
   }
}


